import { defineStore } from "pinia";
import axios from "../axios";

const rechargeStore = defineStore({
    id: 'rechargeStore',
    state: () => ({
        rechargeList: []
    }),

    actions: {
        getrechargeList (data) { 
            return new Promise((reslove, reject) => { 
                axios.get('recharge', { 
                    params: data
                }).then(res => { 
                    reslove(res.data)
                }).catch(err => { 
                    reject(err.data)
                })
            })
        },
        getOrderDetail (data) { 
            return new Promise((reslove, reject) => { 
                axios.get('recharge_detail', {params: data}).then(res => { 
                    reslove(res.data)
                }).catch(err => { 
                    reject(err.data)
                })
            })
        },
        
        // 下单
        toRecharge (data) { 
            return new Promise((resolve, reject) => { 
                axios.post('recharge', data).then(res => { 
                    resolve(res.data)
                }).catch(err => { 
                    reject(err.data)
                })
            })
        }
    }
})

export default rechargeStore